<?php

namespace app\index\controller;

use app\admin\model\PohtoListImage;
use app\admin\model\PohtoMenuModel;
use app\BaseController;

class ImgTest extends BaseController
{
    public function allList()
    {
        $params = $this->request->get(['photo_id']);
        $sql = new PohtoMenuModel();
        $whereArr[] = ["photo_id", "=", $params['photo_id']];
        $list = $sql->where($whereArr)->order('sort asc')
            ->order('create_at asc')->select();
        return result()->success($list);
    }

    public function getImg()
    {
        $params = $this->request->get(['menu_id']);
        $imgSql = new PohtoListImage();
        $whereArr[] = ["menu_id", "=", $params['menu_id']];
        $list = $imgSql
            ->where($whereArr)
            ->order('sort asc')
            ->order('create_at asc')
            ->select()->toArray();
        foreach ($list as $key => $value) {
            // 转成Number类型
            $list[$key]['height'] = (double)$value['height'];
        }
        return result()->success($list);
    }
}